# -*- coding: utf-8 -*-
import re
import scrapy


class RenrenSpider(scrapy.Spider):
    name = 'renren'
    allowed_domains = ['renren.com']
    start_urls = ['http://www.renren.com/964657383/profile']

    def start_requests(self):
        cookies="anonymid=jf7n0t8pumhc40; depovince=GW; jebecookies=5a31461f-fb1b-44dd-93fa-fef7dbc3c35e|||||; _r01_=1; ick_login=6156b5f6-7416-4598-b8c1-a7be058233fb; _de=E6C8D638AC934BB2091539360EA5D908; p=153d7971f4b73127a8fce8b3d0bdc7d13; first_login_flag=1; ln_uact=15638510391; ln_hurl=http://head.xiaonei.com/photos/0/0/men_main.gif; t=438969c8e4038fa3ce47d8feb1ce9da23; societyguester=438969c8e4038fa3ce47d8feb1ce9da23; id=964657383; xnsid=9fc52b63; loginfrom=syshome; ch_id=10016; JSESSIONID=abcLfidLoO0MDeHpToGjw; jebe_key=67226b26-17f0-49ed-94e0-24599a33bb19%7Caf4cb84b112d90473abeb43403206163%7C1522032900080%7C1%7C1522032903329; springskin=set; vip=1; wp_fold=0"
        cookies={i.split("=")[0]:i.split("=")[1] for i in cookies.split("; ")}
        yield scrapy.Request(
            self.start_urls[0],
            callback=self.parse,
            cookies=cookies,
            #headers=headers
        )
    def parse(self, response):
        print(re.findall("谢书悦",response.body.decode()))
        yield scrapy.Request(
            "http://www.renren.com/964657383/profile",
            callback=self.parse_detial
        )
    def parse_detial(self,response):
        print(re.findall("谢书悦",response.body.decode()))